<template>
  <div class="l-rblock l-form-viewer" style="padding:8px;">
    <el-form
      :model="formData"
      :rules="rules"
      size="mini"
      ref="form"
      label-width="80px"
    >
      <div class="l-auto-window ">
        <el-tabs v-model="activeName" type="card">
          <el-tab-pane
            class="l-tabs-container"
            :label="$t('基础信息')"
            name="tab0"
            v-if="lr_hasPageAuth('tab0')"
          >
            <el-row :gutter="0">
              <div class="l-rblock">
                <el-col :span="12" v-if="lr_formLookAuth('f_Account')">
                  <el-form-item :label="$t('账号')" prop="f_Account">
                    <el-input
                      :disabled="
                        !lr_formEditAuth('f_Account', false || isReadOnly)
                      "
                      v-model="formData.f_Account"
                      :readonly="readonlyAccount"
                    ></el-input>
                  </el-form-item>
                </el-col>
                <el-col :span="12" v-if="lr_formLookAuth('f_RealName')">
                  <el-form-item :label="$t('姓名')" prop="f_RealName">
                    <el-input
                      :disabled="
                        !lr_formEditAuth('f_RealName', false || isReadOnly)
                      "
                      v-model="formData.f_RealName"
                    ></el-input>
                  </el-form-item>
                </el-col>
                <el-col
                  :span="12"
                  v-if="lr_formLookAuth('f_CompanyId') && this.isPtUser"
                >
                  <el-form-item :label="$t('公司')" prop="f_CompanyId">
                    <l-tree-select
                      :disabled="
                        !lr_formEditAuth('f_CompanyId', false || isReadOnly)
                      "
                      v-model="formData.f_CompanyId"
                      :placeholder="$t('请选择公司')"
                      :options="lr_companyTree"
                      @change="handleChangeCompany"
                    >
                    </l-tree-select>
                  </el-form-item>
                </el-col>
                <el-col
                  :span="12"
                  v-if="lr_formLookAuth('f_DepartmentId') && this.isPtUser"
                >
                  <el-form-item :label="$t('部门')" prop="f_DepartmentId">
                    <l-tree-select
                      :disabled="
                        !lr_formEditAuth('f_DepartmentId', false || isReadOnly)
                      "
                      v-model="formData.f_DepartmentId"
                      :placeholder="$t('请选择部门')"
                      :options="
                        lr_departmentTree(
                          lr_departments[formData.f_CompanyId] || []
                        )
                      "
                    >
                    </l-tree-select>
                  </el-form-item>
                </el-col>
                <el-col :span="12" v-if="lr_formLookAuth('f_Password')">
                  <el-form-item :label="$t('密码')" prop="f_Password">
                    <el-input
                      :disabled="
                        !lr_formEditAuth('f_Password', false || isReadOnly)
                      "
                      v-model="formData.f_Password"
                      :type="passwordType"
                      :readonly="readonlyPassword"
                    >
                      <i
                        class="el-icon-view el-input__icon"
                        slot="suffix"
                        @click="showPassword"
                      ></i>
                    </el-input>
                  </el-form-item>
                </el-col>
                <el-col :span="12" v-if="lr_formLookAuth('f_Birthday')">
                  <el-form-item :label="$t('生日')" prop="f_Birthday">
                    <l-date
                      :disabled="
                        !lr_formEditAuth('f_Birthday', false || isReadOnly)
                      "
                      v-model="formData.f_Birthday"
                      dateType="date"
                    ></l-date>
                  </el-form-item>
                </el-col>
                <el-col :span="12" v-if="lr_formLookAuth('f_Email')">
                  <el-form-item :label="$t('邮箱')" prop="f_Email">
                    <el-input
                      :disabled="
                        !lr_formEditAuth('f_Email', false || isReadOnly)
                      "
                      v-model="formData.f_Email"
                    ></el-input>
                  </el-form-item>
                </el-col>
                <el-col :span="12" v-if="lr_formLookAuth('f_Mobile')">
                  <el-form-item :label="$t('手机')" prop="f_Mobile">
                    <el-input
                      :disabled="
                        !lr_formEditAuth('f_Mobile', false || isReadOnly)
                      "
                      v-model="formData.f_Mobile"
                    ></el-input>
                  </el-form-item>
                </el-col>
                <el-col :span="12" v-if="lr_formLookAuth('f_Telephone')">
                  <el-form-item :label="$t('电话')" prop="f_Telephone">
                    <el-input
                      :disabled="
                        !lr_formEditAuth('f_Telephone', false || isReadOnly)
                      "
                      v-model="formData.f_Telephone"
                    ></el-input>
                  </el-form-item>
                </el-col>
                <el-col :span="12" v-if="lr_formLookAuth('f_OICQ')">
                  <el-form-item label="QQ" prop="f_OICQ">
                    <el-input
                      :disabled="
                        !lr_formEditAuth('f_OICQ', false || isReadOnly)
                      "
                      v-model="formData.f_OICQ"
                    ></el-input>
                  </el-form-item>
                </el-col>
                <el-col :span="12" v-if="lr_formLookAuth('f_WeChat')">
                  <el-form-item :label="$t('微信')" prop="f_WeChat">
                    <el-input
                      :disabled="
                        !lr_formEditAuth('f_WeChat', false || isReadOnly)
                      "
                      v-model="formData.f_WeChat"
                    ></el-input>
                  </el-form-item>
                </el-col>
                <el-col :span="12" v-if="lr_formLookAuth('f_BindIp')">
                  <el-form-item :label="$t('绑定IP')" prop="f_BindIp">
                    <el-input
                      :disabled="
                        !lr_formEditAuth('f_BindIp', false || isReadOnly)
                      "
                      v-model="formData.f_BindIp"
                    ></el-input>
                  </el-form-item>
                </el-col>
                <!--<el-col :span="12" v-if="lr_formLookAuth('f_DomainName')">
                  <el-form-item label="CA登录名" prop="f_DomainName">
                    <el-input
                      :disabled="
                        !lr_formEditAuth('f_DomainName', false || isReadOnly)
                      "
                      v-model="formData.f_DomainName"
                    ></el-input>
                  </el-form-item>
                </el-col>
                <el-col :span="12" v-if="lr_formLookAuth('f_DomainOnly')">
                  <el-form-item label="仅CA登录" prop="f_DomainOnly">
                    <el-switch
                      :disabled="
                        !lr_formEditAuth('f_DomainOnly', false || isReadOnly)
                      "
                      :active-value="0"
                      :inactive-value="1"
                      v-model="formData.f_DomainOnly"
                    >
                    </el-switch>
                  </el-form-item>
                </el-col>-->
                <el-col :span="12" v-if="lr_formLookAuth('f_IsCheckPassword')">
                  <el-form-item :label="$t('密码验证')" prop="f_IsCheckPassword">
                    <el-switch
                      :disabled="
                        !lr_formEditAuth(
                          'f_IsCheckPassword',
                          false || isReadOnly
                        )
                      "
                      :active-value="0"
                      :inactive-value="1"
                      v-model="formData.f_IsCheckPassword"
                    >
                    </el-switch>
                  </el-form-item>
                </el-col>
                <el-col :span="12" v-if="lr_formLookAuth('f_EnabledMark')">
                  <el-form-item :label="$t('状态')" prop="f_EnabledMark">
                    <el-switch
                      :disabled="
                        !lr_formEditAuth('f_EnabledMark', false || isReadOnly)
                      "
                      :active-value="1"
                      :inactive-value="0"
                      v-model="formData.f_EnabledMark"
                    >
                    </el-switch>
                  </el-form-item>
                </el-col>
                <el-col :span="12" v-if="lr_formLookAuth('f_SortCode')">
                  <el-form-item :label="$t('排序')" prop="f_SortCode">
                    <el-input
                      :disabled="
                        !lr_formEditAuth('f_SortCode', false || isReadOnly)
                      "
                      v-model="formData.f_SortCode"
                    ></el-input>
                  </el-form-item>
                </el-col>
                <el-col :span="24" v-if="lr_formLookAuth('f_Description')">
                  <el-form-item :label="$t('描述')" prop="f_Description">
                    <el-input
                      :disabled="
                        !lr_formEditAuth('f_Description', false || isReadOnly)
                      "
                      type="textarea"
                      v-model="formData.f_Description"
                    ></el-input>
                  </el-form-item>
                </el-col>
              </div>
            </el-row>
          </el-tab-pane>
          <el-tab-pane
            v-if="this.isPtUser && lr_hasPageAuth('tab1')"
            class="l-tabs-container"
            :label="$t('身份信息')"
            name="tab1"
          >
            <el-row :gutter="0">
              <div class="l-rblock">
                <el-col :span="12" v-if="lr_formLookAuth('f_IdCard')">
                  <el-form-item :label="$t('身份证号')" prop="f_IdCard">
                    <el-input
                      :disabled="
                        !lr_formEditAuth('f_IdCard', false || isReadOnly)
                      "
                      v-model="formData.f_IdCard"
                    ></el-input>
                  </el-form-item>
                </el-col>
                <el-col :span="12" v-if="lr_formLookAuth('f_Party')">
                  <el-form-item :label="$t('政治面貌')" prop="f_Party">
                    <l-select
                      :disabled="
                        !lr_formEditAuth('f_Party', false || isReadOnly)
                      "
                      :options="lr_dataItemOptions(lr_dataItem['PartyManage'])"
                      labelKey="f_ItemName"
                      valueKey="f_ItemValue"
                      v-model="formData.f_Party"
                    ></l-select>
                  </el-form-item>
                </el-col>
                <el-col :span="12" v-if="lr_formLookAuth('f_Job')">
                  <el-form-item :label="$t('行政职务')" prop="f_Job">
                    <l-select
                      :disabled="!lr_formEditAuth('f_Job', false || isReadOnly)"
                      :options="lr_dataItemOptions(lr_dataItem['JobManage'])"
                      labelKey="f_ItemName"
                      valueKey="f_ItemValue"
                      v-model="formData.f_Job"
                    ></l-select>
                  </el-form-item>
                </el-col>
                <el-col :span="12" v-if="lr_formLookAuth('f_Level')">
                  <el-form-item :label="$t('行政职级')" prop="f_Level">
                    <l-select
                      :disabled="
                        !lr_formEditAuth('f_Level', false || isReadOnly)
                      "
                      :options="lr_dataItemOptions(lr_dataItem['LevelManage'])"
                      labelKey="f_ItemName"
                      valueKey="f_ItemValue"
                      v-model="formData.f_Level"
                    ></l-select>
                  </el-form-item>
                </el-col>
                <el-col :span="12" v-if="lr_formLookAuth('f_SecretLevel')">
                  <el-form-item :label="$t('用户密级')" prop="f_SecretLevel">
                    <l-select
                      :disabled="
                        !lr_formEditAuth('f_SecretLevel', false || isReadOnly)
                      "
                      :options="f_SecretLevelOptions"
                      v-model="formData.f_SecretLevel"
                    />
                  </el-form-item>
                </el-col>
                <el-col :span="12" v-if="lr_formLookAuth('f_Title')">
                  <el-form-item :label="$t('职称等级')" prop="f_Title">
                    <l-select
                      :disabled="
                        !lr_formEditAuth('f_Title', false || isReadOnly)
                      "
                      :options="lr_dataItemOptions(lr_dataItem['TitleManage'])"
                      labelKey="f_ItemName"
                      valueKey="f_ItemValue"
                      v-model="formData.f_Title"
                    ></l-select>
                  </el-form-item>
                </el-col>
                <el-col :span="12" v-if="lr_formLookAuth('f_Role')">
                  <el-form-item :label="$t('技术职务')" prop="f_Role">
                    <l-select
                      :disabled="
                        !lr_formEditAuth('f_Role', false || isReadOnly)
                      "
                      :options="lr_dataItemOptions(lr_dataItem['RoleManage'])"
                      labelKey="f_ItemName"
                      valueKey="f_ItemValue"
                      v-model="formData.f_Role"
                    ></l-select>
                  </el-form-item>
                </el-col>
                <el-col :span="12" v-if="lr_formLookAuth('f_Post')">
                  <el-form-item :label="$t('管理职务')" prop="f_Post">
                    <l-select
                      :disabled="
                        !lr_formEditAuth('f_Post', false || isReadOnly)
                      "
                      :options="lr_dataItemOptions(lr_dataItem['PostManage'])"
                      labelKey="f_ItemName"
                      valueKey="f_ItemValue"
                      v-model="formData.f_Post"
                    ></l-select>
                  </el-form-item>
                </el-col>
                <el-col :span="12" v-if="lr_formLookAuth('f_WorkerDegree')">
                  <el-form-item :label="$t('职业技能')" prop="f_WorkerDegree">
                    <l-select
                      :disabled="
                        !lr_formEditAuth('f_WorkerDegree', false || isReadOnly)
                      "
                      :options="
                        lr_dataItemOptions(lr_dataItem['WorkerDegreeManage'])
                      "
                      labelKey="f_ItemName"
                      valueKey="f_ItemValue"
                      v-model="formData.f_WorkerDegree"
                    ></l-select>
                  </el-form-item>
                </el-col>
                <el-col :span="12" v-if="lr_formLookAuth('f_Gender')">
                  <el-form-item :label="$t('性别')" prop="f_Gender">
                    <l-radio
                      :disabled="
                        !lr_formEditAuth('f_Gender', false || isReadOnly)
                      "
                      v-model="formData.f_Gender"
                      :options="optionsGender"
                    ></l-radio>
                  </el-form-item>
                </el-col>
              </div>
            </el-row>
          </el-tab-pane>
          <el-tab-pane
            v-if="this.isPtUser && lr_hasPageAuth('tab2')"
            class="l-tabs-container"
            :label="$t('角色信息')"
            name="tab2"
          >
            <el-row :gutter="0">
              <div class="l-rblock">
                <l-edit-table
                  addBtnText="添加角色"
                  :dataSource="formRoles"
                  @addRow="handleAddRole"
                  @deleteRow="handleDeleteRole"
                >
                  <el-table-column v-slot="scope" :label="$t('编号')" width="110">
                    {{ getRoleCode(scope.row.f_ObjectId) }}
                  </el-table-column>
                  <el-table-column
                    v-slot="scope"
                    prop="f_ObjectId"
                    :label="$t('名称')"
                    minWidth="100"
                  >
                    {{ getRoleName(scope.row.f_ObjectId) }}
                  </el-table-column>
                </l-edit-table>
              </div>
            </el-row>
          </el-tab-pane>
          <el-tab-pane
            v-if="this.isPtUser && lr_hasPageAuth('tab3')"
            class="l-tabs-container"
            :label="$t('岗位信息')"
            name="tab3"
          >
            <el-row :gutter="0">
              <div class="l-rblock">
                <l-edit-table
                  addBtnText="添加岗位"
                  :dataSource="formPosts"
                  @addRow="handleAddPost"
                  @deleteRow="handleDeletePost"
                >
                  <el-table-column v-slot="scope" :label="$t('编号')" width="110">
                    {{ getPostCode(scope.row.f_ObjectId) }}
                  </el-table-column>
                  <el-table-column
                    v-slot="scope"
                    prop="f_ObjectId"
                    :label="$t('名称')"
                    minWidth="100"
                  >
                    {{ getPostName(scope.row.f_ObjectId) }}
                  </el-table-column>
                </l-edit-table>
              </div>
            </el-row>
          </el-tab-pane>
          <el-tab-pane
            v-if="this.isPtUser && lr_hasPageAuth('tab4')"
            class="l-tabs-container"
            :label="$t('负责部门')"
            name="tab4"
          >
            <el-row :gutter="0">
              <div class="l-rblock">
                <l-edit-table
                  addBtnText="添加部门"
                  :dataSource="formDepartments"
                  @addRow="handleAddDepartment"
                  @deleteRow="handleDeleteDepartment"
                >
                  <el-table-column v-slot="scope" :label="$t('编号')" width="110">
                    {{ getDepartmentCode(scope.row.f_ObjectId) }}
                  </el-table-column>
                  <el-table-column
                    v-slot="scope"
                    prop="f_ObjectId"
                    :label="$t('名称')"
                    minWidth="100"
                  >
                    {{ getDepartmentName(scope.row.f_ObjectId) }}
                  </el-table-column>
                </l-edit-table>
              </div>
            </el-row>
          </el-tab-pane>
        </el-tabs>
      </div>
    </el-form>

    <l-dialog
      :title="$t('添加角色')"
      :visible.sync="selectRoleVisible"
      :height="480"
      width="800px"
      @ok="handleRoleSelectOk"
      @closed="handleRoleSelectClosed"
    >
      <l-role-select-panel ref="roleSelectPanel"></l-role-select-panel>
    </l-dialog>

    <l-dialog
      :title="$t('添加岗位')"
      :visible.sync="selectPostVisible"
      :height="480"
      width="1024px"
      @ok="handlePostSelectOk"
      @closed="handlePostSelectClosed"
    >
      <l-post-select-panel ref="postSelectPanel"></l-post-select-panel>
    </l-dialog>

    <l-dialog
      :title="$t('添加部门')"
      :visible.sync="selectDepartmentVisible"
      :height="480"
      width="800px"
      @ok="handleDepartmentSelectOk"
      @closed="handleDepartmentSelectClosed"
      @opened="handleDepartmentSelectOpened"
    >
      <l-department-select-panel
        ref="departmentSelectPanel"
      ></l-department-select-panel>
    </l-dialog>
  </div>
</template>
<script>
export default {
  props: {
    isReadOnly: {
      type: Boolean,
      default: false,
    },
  },
  data() {
    return {
      passwordType: "password",

      readonlyAccount: false,
      readonlyPassword: false,
      departmentLoad: false,
      optionsGender: [
        { label: this.$t("男"), value: 1 },
        { label: this.$t("女"), value: 0 },
      ],
      formData: {
        f_SecurityLevel: "",
        f_Account: "",
        f_Password: "",
        f_RealName: "",
        f_HeadIcon: "",
        f_Gender: 1,
        f_Birthday: null,
        f_Mobile: "",
        f_Telephone: "",
        f_Email: "",
        f_OICQ: "",
        f_WeChat: "",
        f_CompanyId: "",
        f_DepartmentId: "",
        f_EnabledMark: 1,
        f_Description: "",
        f_IsCheckPassword: 1, //是否开启密码验证(0是，1否)
        f_BindIp: "", //基础-绑定IP
        f_DomainName: "", //基础-CA登录名
        f_DomainOnly: 1, //基础-是否只能CA登录(默认是0,不是1)
        f_IdCard: "", //身份-身份证号
        f_Party: "", //身份-政治面貌
        f_Job: "", //身份-行政职务
        f_Level: "", //身份-行政职级
        f_SecretLevel: "", //身份-用户密级(0公开，1内部，2秘密，3机密，4绝密)
        f_Title: "", //身份-职称等级
        f_Role: "", //身份-技术职务
        f_Post: "", //身份-管理职务
        f_WorkerDegree: "", //身份-职业技能
        f_SortCode: 99, //排序
      },
      rules: {
        f_Account: [
          { required: true, message: this.$t("请输入账号") },
          {
            validator: this.lr_existDbFiled,
            keyValue: () => {
              return this.formData.f_UserId;
            },
            tableName: "lr_base_user",
            keyName: "f_UserId",
            trigger: "null",
          },
        ],
        f_RealName: [{ required: true, message: this.$t("请输入姓名") }],
        f_CompanyId: [
          { required: true, message: this.$t("请输入公司"), trigger: "blur" },
        ],
        f_DepartmentId: [
          { required: true, message: this.$t("请输入部门"), trigger: "blur" },
        ],
        f_Password: [{ required: true, message: this.$t("请输入密码") }],
        f_DomainName: [
          {
            validator: this.lr_existDbFiled,
            fieldName: "f_DomainName",
            keyValue: () => {
              return this.formData.f_UserId;
            },
            tableName: "lr_base_user",
            keyName: "f_UserId",
            trigger: "null",
          },
        ],
      },

      formRoles: [],
      selectRoleVisible: false,

      formPosts: [],
      selectPostVisible: false,

      formDepartments: [],
      selectDepartmentVisible: false,

      //是否为普通用户
      isPtUser: true,
    };
  },
  created() {
    this.lr_loadDataItem("PartyManage"); //政治面貌
    this.lr_loadDataItem("JobManage"); //行政职务
    this.lr_loadDataItem("LevelManage"); //行政职级
    this.lr_loadDataItem("TitleManage"); //职称等级
    this.lr_loadDataItem("RoleManage"); //技术职务
    this.lr_loadDataItem("PostManage"); //管理职务
    this.lr_loadDataItem("WorkerDegreeManage"); //职业技能
  },
  computed: {
    f_SecretLevelOptions() {
      return [
        { value: 1, label: this.$t("非密") },
        { value: 2, label: this.$t("一般") },
        { value: 3, label: this.$t("重要") },
        { label: this.$t("核心"), value: 4 },
      ];
    },
    activeName: {
      get() {
        return "tab0";
      },
      set() {
        const tabs = ["tab0", "tab1", "tab2", "tab3", "tab4"].filter((t) =>
          this.lr_hasPageAuth(t)
        );
        if (tabs.length > 0) {
          return tabs[0].value;
        } else {
          return "";
        }
      },
    },
  },
  methods: {
    handleChangeCompany() {
      this.formData.f_DepartmentId = "";
    },
    resetForm() {
      this.passwordType = "password";
      this.readonlyPassword = false;
      this.readonlyAccount = false;
      this.formData.f_UserId = "";
      this.activeName = "tab0";
      this.formRoles = [];
      this.formPosts = [];
      this.formDepartments = [];

      this.$refs.form && this.$refs.form.resetFields();
    },
    // 校验表单
    validateForm() {
      return this.$formValidateWraper(this.$refs.form);
    },
    setForm(data) {
      data = this.$deepClone(data);
      if (!data.user.f_SecurityLevel) {
        this.readonlyPassword = true;
        this.isPtUser = true;
      } else {
        this.isPtUser = false;
      }

      this.readonlyAccount = true;
      this.formData = data.user;
      this.formData.f_Password = this.$t("密码明文不展示");

      this.formRoles = data.roles;
      this.formPosts = data.posts;
      this.formDepartments = data.departments;
    },
    getForm() {
      const postData = {
        user: this.$deepClone(this.formData),
      };
      if (this.appConfig.online) {
        postData.user.f_Password = "123456";
      }

      postData.roles = this.$deepClone(this.formRoles);
      postData.posts = this.$deepClone(this.formPosts);
      postData.departments = this.$deepClone(this.formDepartments);

      return postData;
    },

    handleAddRole() {
      this.selectRoleVisible = true;
    },
    handleRoleSelectClosed() {
      this.$refs.roleSelectPanel.resetForm();
    },
    async handleRoleSelectOk() {
      let select = await this.$refs.roleSelectPanel.getForm();
      const selectData = select.map((t) => {
        return { f_Category: 1, f_ObjectId: t.f_RoleId };
      });
      const addData = selectData.filter(
        (t) =>
          this.formRoles.findIndex((t2) => t2.f_ObjectId == t.f_ObjectId) == -1
      );
      this.formRoles.push(...addData);
      this.selectRoleVisible = false;
    },
    handleDeleteRole(data) {
      this.formRoles.splice(data.index, 1);
    },

    handleAddPost() {
      this.selectPostVisible = true;
    },
    handlePostSelectClosed() {
      this.$refs.postSelectPanel.resetForm();
    },
    async handlePostSelectOk() {
      let postList = await this.$refs.postSelectPanel.getForm();
      const selectData = postList.map((t) => {
        return { f_Category: 2, f_ObjectId: t.f_PostId };
      });
      const addData = selectData.filter(
        (t) =>
          this.formPosts.findIndex((t2) => t2.f_ObjectId == t.f_ObjectId) == -1
      );
      this.formPosts.push(...addData);
      this.selectPostVisible = false;
    },
    handleDeletePost(data) {
      this.formPosts.splice(data.index, 1);
    },

    handleAddDepartment() {
      this.selectDepartmentVisible = true;
    },
    handleDepartmentSelectClosed() {
      this.$refs.departmentSelectPanel.resetForm();
    },
    handleDepartmentSelectOpened(){
      this.$refs.departmentSelectPanel.loadData();
    },
    handleDepartmentSelectOk() {
      let select = this.$refs.departmentSelectPanel.getForm()
      const selectData = select.map((t) => {
        return { f_Category: 3, f_ObjectId: t.f_DepartmentId };
      });
      const addData = selectData.filter(
        (t) =>
          this.formDepartments.findIndex(
            (t2) => t2.f_ObjectId == t.f_ObjectId
          ) == -1
      );
      this.formDepartments.push(...addData);
      this.selectDepartmentVisible = false;
    },
    handleDeleteDepartment(data) {
      this.formDepartments.splice(data.index, 1);
    },
    getDepartmentName(value) {
      return this.lr_departmentNameByOne(value);
    },
    getDepartmentCode(value) {
      return this.lr_departmentNameByOne(value, "f_EnCode");
    },

    getRoleName(value) {
      this.lr_loadRole(value);
      return (this.lr_role[value] || {}).f_FullName || "";
    },
    getRoleCode(value) {
      this.lr_loadRole(value);
      return (this.lr_role[value] || {}).f_EnCode || "";
    },
    getPostName(value) {
      this.lr_loadPost(value);
      return (this.lr_post[value] || {}).f_Name || "";
    },
    getPostCode(value) {
      this.lr_loadPost(value);
      return (this.lr_post[value] || {}).f_EnCode || "";
    },

    showPassword() {
      if (this.readonlyPassword) {
        return;
      }
      this.passwordType == ""
        ? (this.passwordType = "password")
        : (this.passwordType = "");
    },
  },
};
</script>
